@extends('layouts/main')
@section('content')
    <style>
        .layui-body{overflow-x: scroll;}
        .error-tip{font-size: 16px;margin-top: 10px;margin-bottom: 10px;}
        .new-table-name{width: 250px;float: left;margin-right: 10px;}
    </style>
    <div style="padding: 15px;">
        @if($db_name)
            <input type="hidden" id="db_name_input" value="{{$db_name}}">
            <input type="hidden" id="table_name_input" value="{{$table_name}}">
            <button class="layui-btn layui-btn-danger" type="button"  onclick="dropTable('{{$table_name}}', '{{$db_name}}')">删除表</button><br>
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    @if($tab=='record')
                        <li class="layui-this">浏览</li>
                    @else
                        <li><a href="/index/record?db_name={{$db_name}}&table_name={{$table_name}}">浏览</a></li>
                    @endif
                    @if($tab=='structure')
                        <li class="layui-this">结构</li>
                    @else
                        <li><a href="/index/structure?db_name={{$db_name}}&table_name={{$table_name}}">结构</a></li>
                    @endif
                    @if($tab=='operation')
                        <li class="layui-this">操作</li>
                    @else
                        <li><a href="/index/operation?db_name={{$db_name}}&table_name={{$table_name}}">操作</a></li>
                    @endif
                </ul>
                <div class="layui-tab-content">
                </div>
            </div>
            <div class="error-tip"></div>
            <div>
                <div id="field_data_content">
                    <div class="filed-line">
                        @foreach($field_data as $k => $v)
                            <div class="layui-form-item" style="width: 100%;">
                                <label class="layui-form-label colunm_name" style="width: 10%;">{{$v['COLUMN_NAME']}}</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="field_content" placeholder="{{$v['COLUMN_COMMENT']}}" value="{{$data['result'][$k]}}" autocomplete="off" class="layui-input field_content">
                                </div>
                            </div>
                        @endforeach
                        <div style="padding-left: 30px;"><input type="button" class="layui-btn layui-btn-danger del-line-btn" value="删除" onclick="deleteLine(this)"></div>
                        <hr>
                    </div>
                </div>
                <div class="layui-form-item" style="padding-left: 30px;">
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="save_btn">保存</button>
                        <button type="button" class="layui-btn layui-btn-normal" id="add_new_line">增加一行</button>
                    </div>
                </div>
            </div>

        @else
            请在左侧选择一个数据库以查看该数据库下的表
        @endif
    </div>
    <script type="text/javascript" src="/js/index/insert.js"></script>
    <script>
        layui.use('element', function(){
            var element = layui.element;
        });
        layui.use('form', function() {
            var form = layui.form;
            form.render();
        });
        line_data = $('#field_data_content').html();

        $('#add_new_line').on('click', function () {
            $('#field_data_content').append(line_data);
        })

    </script>
@endsection